#include "Line.h"

Line::Line()
{
	canvas = NULL;
	d_id = -1;
}
Line::Line(int _x1, int _y1, int _x2, int _y2,DrawingCanvas *_canvas)
{
	canvas = _canvas;
	d_id = canvas->addDrawing(Drawing(_x1,_y1,_x2,_y2,d_line));
}
Line::Line(int _x1, int _y1, int _x2, int _y2, Color c, DrawingCanvas *_canvas)
{
	canvas = _canvas;
	d_id = canvas->addDrawing(Drawing(_x1,_y1,_x2,_y2,c,d_line));
}

void Line::setStart(int _x1, int _y1)
{
	if(canvas != NULL)
		canvas->getDrawing(d_id).setStart(_x1,_y1);
}
void Line::setEnd(int _x2, int _y2)
{
	if(canvas != NULL)
		canvas->getDrawing(d_id).setEnd(_x2,_y2);
}
Location Line::getStart()
{
	if(canvas != NULL)
		return canvas->getDrawing(d_id).getStart();
	return Location(0);
}
Location Line::getEnd()
{
	if(canvas != NULL)
		return canvas->getDrawing(d_id).getEnd();
	return Location(0);
}
